﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DAO;
using DVO;

/// <summary>
/// Summary description for BLL_Working
/// </summary>
public class BLL_Working : WorkingDataContext
{
	public BLL_Working()
	{
		//
		// TODO: Add constructor logic here
		//
	}

    #region "Inser - update"
    public int Insert_Work(Working ObjWork)
    {
        int IdReturn = 0;
        try
        {
            IdReturn = ins_Working_InsertUpdate(ObjWork.WorkName,ObjWork.Author,ObjWork.Notes,ObjWork.Status,ObjWork.Id,ObjWork.ToDate,ObjWork.CreateDate);
        }
        catch (Exception ex)
        {
            Common.WriteLog(ex.Message, ex.StackTrace);
        }
        return IdReturn;
    }

    public int Insert_Comment(int documentid, string comment, string author, int status, int Id, int workid, int ApproveId)
    {
        int IdReturn = 0;
        try
        {
            IdReturn = ins_Comment_Insert(documentid, comment, author, status, Id, workid, ApproveId);
        }
        catch (Exception ex)
        {
            Common.WriteLog(ex.Message, ex.StackTrace);    
        }
        return IdReturn;
    }

  
    #endregion

    #region "Select"
   

    public List<ins_Working_SearchResult> Working_Search(string Id, string WorkName)
    {
        int workdId = 0;
        if (string.IsNullOrEmpty(Id))
        {
            workdId = 0;
        }
        else
        {
            workdId = Convert.ToInt32(Id);
        }
        List<ins_Working_SearchResult> ObjList = new List<ins_Working_SearchResult>();
        try
        {
            ObjList = ins_Working_Search(workdId,WorkName).ToList();
        }
        catch (Exception ex)
        {
            Common.WriteLog(ex.Message, ex.StackTrace);   
        }
        return ObjList;
    }

    public ins_Working_SelectByIdResult Working_SelectById(int Id)
    {
        ins_Working_SelectByIdResult ObjList = new ins_Working_SelectByIdResult();
        try
        {
            ObjList = ins_Working_SelectById(Id).SingleOrDefault();
        }
        catch (Exception ex)
        {
            Common.WriteLog(ex.Message, ex.StackTrace);
        }
        return ObjList;
    }

    public List<ins_Comment_SelectByDocIdResult> Comment_SelectById(int id)
    {
        List<ins_Comment_SelectByDocIdResult> ObjList = new List<ins_Comment_SelectByDocIdResult>();
        try
        {
            ObjList = ins_Comment_SelectByDocId(id).ToList();
        }
        catch (Exception ex)
        {
            Common.WriteLog(ex.Message, ex.StackTrace);
        }
        return ObjList;
    }
    #endregion

    #region "member"
  
    public ins_Member_SelectByUserNameResult Login(string username, string pass)
    {
        ins_Member_SelectByUserNameResult ObjInfo = new ins_Member_SelectByUserNameResult();
        try
        {
            ObjInfo = ins_Member_SelectByUserName(username, pass).SingleOrDefault();
        }
        catch (Exception ex)
        {
            Common.WriteLog(ex.Message, ex.StackTrace);
        }
        return ObjInfo;

    }
    #endregion

    #region "Report"
    public List<ins_ToolQA_Report_WorkingResult> Report()
    {
        List<ins_ToolQA_Report_WorkingResult> ObjList = new List<ins_ToolQA_Report_WorkingResult>();
        try
        {
            ObjList = ins_ToolQA_Report_Working().ToList();
        }
        catch (Exception ex)
        {
            Common.WriteLog(ex.Message, ex.StackTrace);
        }
        return ObjList;

    }
    #endregion

}